package com.cp.yn.utils;
import android.content.Context;
import android.view.Display;
import android.view.WindowManager;
import android.view.Surface;

import com.common.base.tools.utils.Logs;

public class ScreenRotationHelper {

    private static int getScreenRotation(Context context) {
        WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        Display display = windowManager.getDefaultDisplay();
        return display.getRotation();
    }

    public static void getRotation(Context context) {
        // 假设你有一个Context对象，例如从Activity中传入  
        int rotation = getScreenRotation(context);
        switch (rotation) {
            case Surface.ROTATION_0:
                Logs.info("屏幕没有旋转");
                break;
            case Surface.ROTATION_90:
                 Logs.info("屏幕顺时针旋转了90度");
                break;
            case Surface.ROTATION_180:
                 Logs.info("屏幕旋转了180度");
                break;
            case Surface.ROTATION_270:
                 Logs.info("屏幕逆时针旋转了90度");
                break;
            default:
                 Logs.info("未知的屏幕旋转角度");
                break;
        }
    }
}
